<template>
	<view class="container">
		<uni-section title="食物轮播图展示" type="line">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
				<swiper-item v-for="item in list">
					<view class="swiper-item">
						<image :src="'http://localhost:8090'+item.icon" mode="" style="width:100%;height:180px"></image>
					</view>
				</swiper-item>
			</swiper>
		</uni-section>
		<uni-section title="食品类别宫格展示" type="line">
			<uni-grid :column="3">
				<uni-grid-item v-for="item in data">
					<view style="display:flex;flex-direction: column;align-items: center;padding-top: 10px;">
						<image :src="'http://localhost:8090'+item.icon" mode="" style="width: 80px;height: 80px;">
						</image>
						<view class="">
							{{item.typename}}
						</view>
					</view>
				</uni-grid-item>
			</uni-grid>
		</uni-section>
		<uni-section title="食品列表展示(3条)" type="line">
			<uni-list>
				<navigator url="../fooddetail/fooddetail">
				<uni-list-item v-for="item in liebiao" :title="item.name" :thumb="'http://localhost:8090'+item.icon"
					:rightText="'￥'+item.price+'元'">
				</uni-list-item>
				</navigator>
			</uni-list>
		</uni-section>
		<uni-section title="食品评论列表展示(3条)" type="line">
			<navigator url="../../comment/commentlist/commentlist">
			<uni-list>
				<uni-list-item v-for="item in haochi" :title="item.comment" :rightText="item.postdate"></uni-list-item>
			</uni-list>
			</navigator>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: {},
				data: {},
				liebiao: {},
				haochi: {}
			}
		},
		methods: {

		},
		onLoad() {
			uni.request({
				url: 'http://localhost:8090/foodapp/foodSwiper/list',
				method: 'post',
				success: res => {
					if (res.data.success) {
						this.list = res.data.list
					}
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/foodType/list',
				method: 'post',
				success: res => {
					if (res.data.success) {
						this.data = res.data.list
					}
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/food/list',
				method: 'post',
				success: res => {
					if (res.data.success) {
						this.liebiao = res.data.list
					}
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/comment/list',
				method: 'post',
				success: res => {
					if (res.data.success) {
						this.haochi = res.data.list
					}
				},
				fail: () => {},
				complete: () => {}
			});
		}
	}
</script>

<style>
</style>
